<?php
$filename='now_time.txt';
if (!file_exists($filename)) {
require("func.php");
ignore_user_abort(); 
set_time_limit(0);
$interval=1; // 每隔1秒运行
$send=0;
do{
include('conf.php'); // 引入文件
if(!$c['r']) break; // 如果
$time = date("Y-m-d")." 18:00:00";
$time1 = date("Y-m-d H:i:s",time());
$sed = (strtotime($time)-strtotime($time1));
writeTime($filename);
if($sed>0 && $send==1)
{
	$send=0;
}
if($sed<0 && $send==0)
{
	$send=1;
	SendAllPhone();
}
sleep($interval); // 等待10秒
}while(true);
}
function writeTime($filename)
{
$fp = fopen($filename, "w");//文件被清空后再写入
if($fp)
{
fwrite($fp,date("Y-m-d H:i:s",time()));
fclose($fp); 
}
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试自动发送是否运行</title>
<meta http-equiv="refresh" content="1">
</head>

<body>
<?php
$fp = fopen($filename, "r");
$time1 = date("Y-m-d H:i:s",time());
if($fp)while(!feof($fp))
{
	$time=fgets($fp);
	echo $time. "<br />";
}
fclose($fp); 
$sed = (strtotime($time1)-strtotime($time));
if($sed>10)
if (file_exists($filename)) {
    $result=unlink ($filename);
  }
?>
</body>
</html>